//
//  MyCollectViewController.m
//  OrderSeat
//
//  Created by haiming on 13-10-7.
//  Copyright (c) 2013年 wangwei. All rights reserved.
//

#import "MyCollectViewController.h"
#import "ShopCollectView.h"
#import "GourmetCollectView.h"

@implementation MyCollectViewController

- (id)init
{
    self = [super initWithNibClass:[MyCollectViewController class]];
    if (self) {

    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self setupUI];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [[AppDelegate sharedInstance] hideTabBar:self.tabBarController];
}

- (void)setupUI
{
    [self createLeftButton];
    [self setNavigationTitle:@"我的收藏"];
    
    self.shopCollectView = [self createViewWithType:0];
}

- (id)createViewWithType:(int)type
{
    CGRect frame = CGRectMake(0, _btnShop.bottom, ScreenWidth, ScreenHeight-_btnShop.bottom);
    if (type == 0) {
        ShopCollectView *collectView  = [[ShopCollectView alloc] initWithFrame:frame];
        collectView.collectVC = self;
        [self.view addSubview:collectView];
        return collectView;
    }
    if (type == 1) {
        GourmetCollectView *collectView  = [[GourmetCollectView alloc] initWithFrame:frame];
        collectView.collectVC = self;
        [self.view addSubview:collectView];
        return collectView;
    }
    return nil;
}

- (void)leftButtonClick:(id)sender
{
    [[AppDelegate sharedInstance] showTabBar:self.tabBarController];
    [self.navigationController popViewControllerAnimated:YES];
}

- (IBAction)selAction:(id)sender
{
    _btnShop.selected = _btnCourmet.selected = NO;
    [sender setSelected:YES];
    
    if (!_shopCollectView) self.shopCollectView = [self createViewWithType:0];
    if (!_gourmetCollectView) self.gourmetCollectView = [self createViewWithType:1];
    
    _shopCollectView.hidden = !_btnShop.selected;
    _gourmetCollectView.hidden = !_btnCourmet.selected;
    
}


@end